﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace TSharp.Core.Repository
{
    /// <summary>
    /// 可直接执行sql语句的接口，不建议使用此接口内方法
    /// </summary>
    public interface ISql
    {
        /// <summary>
        /// Executes the given DDL/DML command against the database.
        /// 
        /// </summary>
        /// <param name="sql">The command string.</param><param name="parameters">The parameters to apply to the command string.</param>
        /// <returns>
        /// The result returned by the database after executing the command.
        /// </returns>
        int ExecuteSqlCommand(string sql, params object[] parameters);
        /// <summary>
        /// Creates a raw SQL query that will return elements of the given generic type.
        ///                 The type can be any type that has properties that match the names of the columns returned
        ///                 from the query, or can be a simple primitive type.  The type does not have to be an
        ///                 entity type. The results of this query are never tracked by the context even if the
        ///                 type of object returned is an entity type.  Use the <see cref="M:System.Data.Entity.DbSet`1.SqlQuery(System.String,System.Object[])"/>
        ///                 method to return entities that are tracked by the context.
        /// 
        /// </summary>
        /// <typeparam name="TElement">The type of object returned by the query.</typeparam><param name="sql">The SQL query string.</param><param name="parameters">The parameters to apply to the SQL query string.</param>
        /// <returns>
        /// A <see cref="T:System.Collections.Generic.IEnumerable`1"/> object that will execute the query when it is enumerated.
        /// </returns>
        IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters);
        /// <summary>
        /// Creates a raw SQL query that will return elements of the given type.
        ///                 The type can be any type that has properties that match the names of the columns returned
        ///                 from the query, or can be a simple primitive type.  The type does not have to be an
        ///                 entity type. The results of this query are never tracked by the context even if the
        ///                 type of object returned is an entity type.  Use the <see cref="M:System.Data.Entity.DbSet.SqlQuery(System.String,System.Object[])"/>
        ///                 method to return entities that are tracked by the context.
        /// 
        /// </summary>
        /// <param name="elementType">The type of object returned by the query.</param><param name="sql">The SQL query string.</param><param name="parameters">The parameters to apply to the SQL query string.</param>
        /// <returns>
        /// A <see cref="T:System.Collections.IEnumerable"/> object that will execute the query when it is enumerated.
        /// </returns>
        IEnumerable SqlQuery(Type elementType, string sql, params object[] parameters);
    }
}